class Colorful {
    constructor() {
        this.randomColor()
    }

    night() {
        return window.matchMedia('(prefers-color-scheme: dark)').matches
    }

    randomArray(range) {
        const length = range.length
        const randomIndex = Math.floor(length * Math.random())
        return range[randomIndex]
    }

    randomColor() {
        let range = ['8', '9', 'A', 'B', 'C', 'D', 'E', 'F']
        return '#' + this.randomArray(range) + this.randomArray(range) + this.randomArray(range) + this.randomArray(range) + this.randomArray(range) + this.randomArray(range)
    }
}

let colorful = new Colorful();

export default colorful;